package com.shujia.userController;

import com.shujia.uerService.userService;
import com.shujia.user.Message;

import java.util.Scanner;

public class userController {
    static userService userService = new userService();
    public static void main(String[] args) {
            int s = 1;
        try {
            while(s!=0){
                System.out.println("请输入选项");
                System.out.println("0.退出 1.登陆 2.注册 3.修改密码");
                System.out.println("====================");
                Scanner scanner = new Scanner(System.in);
                s = scanner.nextInt();
                switch (s){
                    case 1: userController.login(); break;
                    case 2: userController.insert(); break;
                    case 3: userController.update(); break;
                }
            }
        } catch (Exception e) {
            System.out.println("请按指示操作");
        }
        System.out.println("bye");
    }
    public static void login(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入账号");
        String username = scanner.next();
        System.out.println("请输入密码");
        String password = scanner.next();

        Message login = userService.login(username,password);
        System.out.println(login);
    }
    public static void insert(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入账号");
        String username = scanner.next();
        System.out.println("请输入密码");
        String password = scanner.next();
        System.out.println("确认密码");
        String password1 = scanner.next();
        String s = userService.insertinto(username, password, password1);
        System.out.println(s);
    }
    public static void update(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入账号");
        String username = scanner.next();
        System.out.println("请输入密码");
        String password = scanner.next();
        System.out.println("请输入新密码");
        String newpassword = scanner.next();
        System.out.println("请确认密码");
        String newpassword1 = scanner.next();
        String s = new userService().updateuser(username, password, newpassword, newpassword1);
        System.out.println(s);
    }
}
